 |
 |
 |
 |
 |
 |
 |
 |
The keyword
new is used to initialise pointers with
|
|
memory from
free store (a section of memory available
|
|
to all
programs).
|
|
|
int
*ptr = new int;
|
|
|
It initialises
ptr to point to a memory address of size int
|
|
(because
variables have different sizes, number of
|
|
bytes, this is
necessary). The memory that is pointed to
|
becomes
unavailable to other programs. This means
|
|
that the
careful coder will free this memory at the end
|
|
of its usage.
|
|